<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
import { showLoading, hideLoading } from '@/utils/base'
export default {
  data() {
    return {
      timer: null,
      timerTime: 0,
    };
  },
  mounted() {
    showLoading()
    // sessionStorage.setItem('appToken', 'AQIC5wM2LY4Sfcw0KjEohiyqx7P8RCHJmgf7juRAhS6fpSc.*AAJTSwABMQ..*')
    this.timer = setInterval(() => {
      this.timerTime++
      if (this.timerTime > 10) {
        clearInterval(this.timer);
        hideLoading()
        this.$router.push('/403')
      }
      if (sessionStorage.getItem("appToken")) {
        this.$store.commit("SET_TOKEN", sessionStorage.getItem("appToken"));
        this.$store.dispatch("getUser");
        clearInterval(this.timer);
        this.timer = null;
      }
    }, 500)
  },
  created() {
    setTimeout(function () {
      let children = document.querySelector("body").children;
      if (children.length) {
        let domId = Array.from(children).find((item) => item.id === "app");
        if (children[0].clientHeight == 60) {
          domId.classList.add("is");
        } else {
          domId.classList.remove("is");
        }
      }
    }, 100);
  },
};
</script>

<style lang="less">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  max-height: 100vh;
  flex: 1;
  width: 100vw;
  overflow: hidden;
  color: #202439;
  display: flex;
  flex-direction: column;

  &.is {
    max-height: calc(100vh - 60px);
  }
}

nav {
  padding: 30px;
}

nav a {
  font-weight: bold;
  color: #2c3e50;
}

nav a.router-link-exact-active {
  color: #42b983;
}
</style>
